<template>
  <div style="">
    <pageTop :logoPic="logoPic"></pageTop>

<div style="width: 100%;height: auto;background: #fff">
  <div class="body" style="margin: 0px auto;">
    <div class="newsTitle">{{newsDetail.title}}</div>
    <p class="nameTime"><span>作者：{{newsDetail.author}}</span> <span style="">&nbsp;&nbsp;&nbsp;&nbsp;时间：{{time*1000 | formatDate}}</span></p>
    <p class="content" v-html="newsDetail.content">
      
    </p>
  </div>
</div>


    <pageBottom :napinAddress="way.position"></pageBottom>
  </div>
</template>

<script>
// import pageTop from '../components/pageTop'
import pageTop from '../components/common/pageTop'
import pageBottom from '../components/common/pageBottom'
import request from '@/request/index.js' 
export default {
  name: 'newsDetail',
  components: {
    pageTop,
    pageBottom

  },
  filters: {
    formatDate: function (value) {
      let date = new Date(value)
      let y = date.getFullYear()
      let MM = date.getMonth() + 1
      MM = MM < 10 ? ('0' + MM) : MM
      let d = date.getDate()
      d = d < 10 ? ('0' + d) : d
      let h = date.getHours()
      h = h < 10 ? ('0' + h) : h
      let m = date.getMinutes()
      m = m < 10 ? ('0' + m) : m
      let s = date.getSeconds()
      s = s < 10 ? ('0' + s) : s
      return y + '-' + MM + '-' + d + ' '
    }
  },
  data () {
    return {
      text: '新闻中心',
      newsDetail: [],
      time: [],
      way:{},
      logoPic:"",
      /* id:'$route.params.id', */
    }
  },
  created () {
    this.loading=this.$loading({
      lock: true,
      // text: 'Loading',
      // spinner: 'el-icon-loading',
      background: 'rgba(255, 255, 255, 0.6)',
      target: document.querySelector('body'),
      
    });
    const id = this.$route.query.id;

    var that = this
    this.axios({
      url: '/offcial/index.php/index/Acticle/NewsContenr',
      method: 'post',
      data: {
        nid: id,
        time: this._globe.time1,
        device_id: this._globe.device_id,
        version: this._globe.version,
        platform: this._globe.platform,
        token: this._globe.token1
      }
    })
    .then(function (response) {
      /* console.log(response); */
      const resData = response.data
      if (resData.code == 1) {
        that.newsDetail = resData.data
        that.time = resData.data.create_time
        /* console.log(that.newsDetail); */
      }
    })
    .catch(function (response) {
      console.log(response);
      
    })
    
  request.GetContact(this);
  request.home(this);
  },
  methods: {
    getParams () {
      // 取到路由带过来的参数
      var routerParams = this.$route.params.id
      // 将数据放在当前组件的数据内
      this.id = routerParams
    },
  }
}
</script>

<style scoped lang="scss">
  .body{
    width: 1200px;
    height:  auto;
    background: #fff;
    border-top: 1px solid #f5f5f5;
      .newsTitle{
        text-align: center;
        font-weight:600;
        font-size: 20px;
        color: #333;
        text-align: left;
        margin: 0px auto;
        text-align: center;
        margin-top: 40px;
      }
    .nameTime{
      font-size: 16px;
      margin-top: 40px;
      color: #666;
      -webkit-box-sizing: border-box;
      -moz-box-sizing: border-box;
      box-sizing: border-box;
      // padding-left: 5vw;
      text-align: center;
    }
    .content{
      border-top:1px solid #f5f5f5;
      padding-top: 40px;
      margin-top: 20px;
      font-size: 16px;
      color: #333;
      height: auto;
      // letter-spacing: .5vw;
      text-align: left;
      line-height: 2em;
      text-indent: 2rem;
    }
  }
@media screen and (max-width: 375px) and (min-width: 320px){
  .newsTitle{
    font-size: 18px !important;
  }
}
</style>
